/**
 * 
 */
package d.qapaper.main;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.security.auth.PrivateCredentialPermission;

import android.content.Context;
import android.view.View;
import d.qapaper.bean.CategoriesInfo;
import d.qapaper.bean.Question;

/**
 * @author Kaven
 * 2011-5-6
 * 对问卷问题进行分类处理
 */
public class questionArraySort {
	private HashMap<String, String> config;
	private String isShow="";
	public questionArraySort(HashMap<String, String> config,String isShowInput){
		this.config=config;
		this.isShow=isShowInput;
	}
	public HashMap<String,Object> sortQuestion(Context qa,List<CategoriesInfo> catlist,List<Question> qusList){
		HashMap<String,Object> cateMap=new HashMap<String,Object>();
		List<View> questionViews=null;
		createViewItem createViewItem=new createViewItem(qa,isShow);
		for (CategoriesInfo cat :catlist) {
			cateMap.put(cat.getCid()+"_name", cat.getCname());
			questionViews=new ArrayList<View>();
			for (Question question : qusList) {
				if(cat.getCid().equals(question.getCid())){
					questionViews.add(createViewItem.createViewItem(question,this.config));
				}
			}
			cateMap.put(cat.getCid(), questionViews);
		}
		return cateMap;
	}
}
